from django.db import models


# Create your models here.

class Vehicle(models.Model):
    user_id = models.BigIntegerField(verbose_name="关联用户ID")
    plate_number = models.CharField(max_length=20, verbose_name="车牌号")
    model = models.CharField(max_length=50, verbose_name="车辆型号")
    color = models.CharField(max_length=20, verbose_name="车辆颜色")
    status = models.SmallIntegerField(choices=[(0, "正常"), (1, "禁用")], default=0, verbose_name="车辆状态")
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)


class VehicleImage(models.Model):
    vehicle = models.ForeignKey(Vehicle, on_delete=models.CASCADE)
    image_url = models.CharField(max_length=255)
    upload_time = models.DateTimeField(auto_now=True)
    audit_status = models.SmallIntegerField(choices=[(0, "未审核"), (1, "通过"), (2, "驳回")], default=0)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)


class VehicleViolation(models.Model):
    vehicle = models.ForeignKey(Vehicle, on_delete=models.CASCADE)
    violation_time = models.DateTimeField()
    location = models.CharField(max_length=255, blank=True, null=True)
    violation_type = models.CharField(max_length=100)
    penalty_amount = models.DecimalField(max_digits=10, decimal_places=2, blank=True, null=True)
    penalty_points = models.IntegerField(blank=True, null=True)
    status = models.SmallIntegerField(choices=[(0, "未处理"), (1, "已处理")], default=0)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
